<%@include file="connection.jsp" %>
<%
String op=request.getParameter("op");
String pf_id=request.getParameter("pf");

if(op.equals("del"))
{
   
    String id=request.getParameter("val");
    
    st=con.createStatement();
    rs=st.executeQuery("select pf_id from pf_detail where sr_no='"+id+"'" );
    
    while(rs.next())
        pf_id=rs.getString(1);
    
    st=con.createStatement();
    int i=st.executeUpdate("delete from pf_detail where sr_no='"+id+"'" );
    
    
    response.sendRedirect("portfolio.jsp?pid="+pf_id);
    
}
if(op.equals("update")){
    String com=request.getParameter("com_name").toString();
    String qty=request.getParameter("quanti");
    String price=request.getParameter("price");
    String date=request.getParameter("date");
    String pf=request.getParameter("pf");
    String id=request.getParameter("hid");
    
    //out.print(com+qty+price+date+pf);
    
    st=con.createStatement();
    rs=st.executeQuery("select com_id from company where ticker='"+com+"'");
    
    while(rs.next()){
        com=rs.getString("com_id");
    }
    
    int i=st.executeUpdate("update pf_detail set com_id='"+com+"',buy_price='"+price+"',buy_qty='"+qty+"',date='"+date+"' where sr_no="+id+"");
    response.sendRedirect("portfolio.jsp?pid="+pf);
}


%>